Skip to content

feat: stalign with a fit apply pattern. Also foundation for imputation#1195

Open
selmanozleyen wants to merge 121 commits into
scverse:mainfrom
selmanozleyen:feat/experimental-fit-core
Open

feat: stalign with a fit apply pattern. Also foundation for imputation#1195
selmanozleyen wants to merge 121 commits into
scverse:mainfrom
selmanozleyen:feat/experimental-fit-core

Conversation

@selmanozleyen

Copy link
Copy Markdown
Member

Continuation of #1162

selmanozleyen and others added 30 commits April 2, 2026 13:06
@selmanozleyen selmanozleyen requested a review from timtreis June 8, 2026 09:44
@codecov

codecov Bot commented Jun 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 45.00000% with 308 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.71%. Comparing base (55572c4) to head (30e14cf).

Files with missing lines Patch % Lines
...ntal/_methods/align_samples/_stalign_impl/_core.py 0.00% 156 Missing ⚠️
...l/_methods/align_samples/_stalign_impl/_helpers.py 0.00% 73 Missing ⚠️
...tal/_methods/align_samples/_stalign_impl/_tools.py 51.94% 37 Missing ⚠️
...experimental/_methods/align_landmarks/_landmark.py 84.12% 6 Missing and 4 partials ⚠️
...py/experimental/_methods/align_samples/_stalign.py 37.50% 9 Missing and 1 partial ⚠️
src/squidpy/experimental/tl/_align/_api.py 72.22% 9 Missing and 1 partial ⚠️
src/squidpy/experimental/_methods/_protocols.py 66.66% 2 Missing and 3 partials ⚠️
src/squidpy/experimental/tl/_align/_io.py 93.90% 3 Missing and 2 partials ⚠️
src/squidpy/experimental/_methods/_registry.py 94.59% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1195      +/-   ##
==========================================
- Coverage   76.55%   74.71%   -1.84%     
==========================================
  Files          63       73      +10     
  Lines        9067     9627     +560     
  Branches     1521     1590      +69     
==========================================
+ Hits         6941     7193     +252     
- Misses       1541     1837     +296     
- Partials      585      597      +12     
Files with missing lines Coverage Δ
src/squidpy/experimental/_methods/_families.py 100.00% <100.00%> (ø)
src/squidpy/experimental/_methods/_registry.py 94.59% <94.59%> (ø)
src/squidpy/experimental/_methods/_protocols.py 66.66% <66.66%> (ø)
src/squidpy/experimental/tl/_align/_io.py 93.90% <93.90%> (ø)
...experimental/_methods/align_landmarks/_landmark.py 84.12% <84.12%> (ø)
...py/experimental/_methods/align_samples/_stalign.py 37.50% <37.50%> (ø)
src/squidpy/experimental/tl/_align/_api.py 72.22% <72.22%> (ø)
...tal/_methods/align_samples/_stalign_impl/_tools.py 51.94% <51.94%> (ø)
...l/_methods/align_samples/_stalign_impl/_helpers.py 0.00% <0.00%> (ø)
...ntal/_methods/align_samples/_stalign_impl/_core.py 0.00% <0.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

"AlignResult",
"StitchParams",
"TilingQCParams",
"assign_stitch_groups",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

format

# element we register a transform on so `output_mode="copy"` leaves the input untouched.
element = sd_deepcopy(element)
getattr(out, etype)[name] = element
set_transformation(element, sd_affine, to_coordinate_system=target_cs)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

breaks if the element already has a transformation, you need to Sequence them

existing = get_transformation(element, to_coordinate_system=moving_cs)
set_transformation(element, Sequence([existing, sd_affine]), to_coordinate_system=target_cs)

radius = int(np.ceil(float(np.max(blur_values)) * 4.0))
denom = 2.0 * (dx * blur_values * 2.0) ** 2

for x_i, y_i in zip(x, y, strict=False):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How many points do we have? Should probably rasterize

p: float = 2.0,
expand: float = 2.0,
nt: int = 3,
niter: int = 5000,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we do some form of early stopping or do we always have to train for 5k steps? Might be too much/too little depending on data

return data_ref.tables[ref_key], sdata_query.tables[query_key], sdata_query, query_key


def get_coords(adata: AnnData, spatial_key: str) -> np.ndarray:

@timtreis timtreis Jun 16, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude:

get_coords materializes coords up to 3× per align() (_io.py:71; called at _api.py:83,84 and again _io.py:97). np.asarray(..., dtype=float) forces a float64 copy each time. Thread the already-computed query_xy into writeback_obs and avoid the forced upcast when the array is already suitable.

Comment thread pyproject.toml
"zarr>=3",
]
optional-dependencies.jax = [
"jax",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we have some lower bound?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants